<!DOCTYPE html>
<html class="x-admin-sm" xmlns:th="http://www.thymeleaf.org">

<head>
    <meta charset="UTF-8">
    <title>欢迎</title>
    <th:block th:include="include::header"/>
</head>
<body>
<div class="layui-fluid">
    <div class="layui-row">
        <form class="layui-form" th:object="${dispatch}">
            <input type="hidden" id="id" name="id" th:value="*{id}" required="" lay-verify="">
            <div class="layui-form-item">
                <label class="layui-form-label">作业编号</label>
                <div class="layui-input-inline">
                    <select id="number" name="work" lay-verify="required" class="select">
                        <th:block th:each="item:${workList}" th:object="${item}">
                            <option th:value="*{number}" th:selected="${dispatch.work==item.number?'true':'false'}">[[*{number}]]</option>
                        </th:block>
                    </select>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">生产编号</label>
                <div class="layui-input-inline">
                    <select id="plan" name="plan" lay-verify="required" class="select">
                        <th:block th:each="item:${planList}" th:object="${item}">
                            <option th:value="*{id}" th:selected="${dispatch.plan==item.id?'true':'false'}">[[*{id}]]</option>
                        </th:block>
                    </select>
                </div>
            </div>
            <div class="layui-form-item">
                <label for="total" class="layui-form-label">
                    <span class="x-red"></span>派工数量</label>
                <div class="layui-input-inline">
                    <input type="text" id="total" name="total" required="" lay-verify="number" th:value="*{total}"
                           autocomplete="off" class="layui-input"></div>
            </div>
            <div class="layui-form-item">
                <label for="hours" class="layui-form-label">
                    <span class="x-red"></span>派工工时</label>
                <div class="layui-input-inline">
                    <input type="text" id="hours" name="hours" required="" lay-verify="number" th:value="*{hours}"
                           autocomplete="off" class="layui-input"></div>
            </div>

            <div class="layui-form-item">
                <button class="layui-btn" lay-filter="edit" lay-submit="">修改</button>
            </div>
        </form>
    </div>
</div>
<script>layui.use(['form', 'layer', 'jquery'],
    function () {
        $ = layui.jquery;
        var form = layui.form,
            layer = layui.layer;
        //监听提交
        form.on('submit(edit)',
            function (data) {
                //发异步，把数据提交给php
                $.ajax({
                    url: "/dispatch/editDispatch",
                    type: "POST",
                    data: data.field,
                    success(res) {
                        layer.alert("修改成功", {
                                icon: 6
                            },
                            function () {
                                //关闭当前frame
                                xadmin.close();
                                // 可以对父窗口进行刷新
                                xadmin.father_reload();
                            });
                    }
                })
                return false;
            });
    });</script>
</body>

</html>